package com.neuedu.javase.operation;

/**
 * @author :金山老师
 * project: MyJavaSE
 * 描述 ： 算数运算符
 * @date : 2025/10/16 13:45
 */
public class OperationArithmetic {
    /*
        +  -  *   /   ++ -- %
        main
     */
    public static void main(String[] args) {
        int numa = 10;
        int numb = 5;
        int numc = 3;

        double dubleNuma = 10.0;
        double dubleNumb = 3.0;

        // 选中同名单词 ALT+J
        System.out.println("("+numa+" + "+numb+") = " + (numa + numb));
        System.out.println("("+numa+" - "+numb+") = " + (numa - numb));
        System.out.println("("+numa+" * "+numb+") = " + (numa * numb));


        System.out.println("("+numa+" / "+numb+") = " + (numa / numb));
        System.out.println("("+numa+" / "+numc+") = " + (numa / numc));// 3
        System.out.println("("+dubleNuma+" / "+dubleNumb+") = " + (dubleNuma / dubleNumb));// 3.3333333333333335




        //取余   求模
        System.out.println("(10 % 5) = " + (10 % 5));   //   0
        System.out.println("(10 % 3) = " + (10 % 3));   //   1
        System.out.println("(10 % 4) = " + (10 % 4));   //   2


        // ++ --
        int numd = 2;
        numd++;  //相当于    numd  = numd + 1;

        System.out.println("numd = " + numd);


        int nume = 5;

        // int resultPlus =  (nume++) * 2;
        int resultPlus =  ++nume * 2;
        System.out.println("nume = " + nume); // 6
        System.out.println("resultPlus = " + resultPlus); // 10 或者 12



        int numf = 8;

        // int resultPlus2 = numf-- * 2;
        int resultPlus2 = --numf * 2;
        System.out.println("numf = " + numf); // 7
        System.out.println("resultPlus2 = " + resultPlus2); // 16 或者 14


        System.out.println("10+20 等于 " +  10 + 20 );  // 10+20 等于1020 字符串拼接的问题
        System.out.println("10+20 等于 " +  (10 + 20 ));  // 10+20 等于30

        // (10 + 20).soutv
        System.out.println("( 10 + 20) = " + (10 + 20));


        // 10 / 3  =  3
        // 10 / 3.0  =  3.3333333333333335
        System.out.println(" 10 / 3.0  = " + (10  /  3.0 ));

    }
}
